
$.fn.readyAndPostBack = function(func){
	$(this).ready(func);
	$(this).ajaxComplete(func);
};

$.fn.postBack = function(func){
	$(this).ajaxComplete(func);
};

$.fn.oncePostBack = function(func,param){
	
	var f = function(func, param){
		
		if (Ajax.hasConnection == false){
			
			if (param == undefined){
				func();
			}else{
				func(param);
			}
		}else{
			alert("timer");
			setTimeout(function(){f(func,param);}, 500);
		}
	};
	
	setTimeout(function(){f(func,param);}, 10);
};

var Ajax = {
	hasConnection: false
};

$(document).ajaxStart(function(){
	Ajax.hasConnection = true;
});

$(document).ajaxComplete(function(){
	Ajax.hasConnection = false;
});
